﻿namespace EFS.RC.SupervisorCentral.Controls.Agents
{
	public partial class ContactListItemNotTalking : ContactListItem
	{
		public ContactListItemNotTalking()
		{
			InitializeComponent();

			// ignore in design tool
			if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
			{
				this.Loaded += new System.Windows.RoutedEventHandler(ContactListItemNotTalking_Loaded);

				// set events
				buttonAddRemoveACD.Click += new System.Windows.RoutedEventHandler(buttonAddRemoveACD_Click);
			}
		}

		#region Properties
		/// Property CustomContactListItem: Get
		protected override Microsoft.Lync.Controls.CustomContactListItem LyncCustomContactListItem
		{
			get
			{
				return controlCustomContactListItem;
			}
		}

		/// Property ButtonAddRemoveACDType: Get
		private eButtonType ButtonAddRemoveACDType
		{
			get
			{
				// button type
				eButtonType buttonType = eButtonType.AddToACD;

				// get array
				EFS.RC.CC.Messages.Agents.Status[] statusArray =
					EFS.RC.SupervisorCentral.Common.Session.Instance.AgentList.Filter(
						Source,
						null,
						null,
						null,
						null,
						null,
						true,
						ACD);

				// test array
				if (EFS.Common.Verify.Array(statusArray))
				{
					buttonType = eButtonType.RemoveFromACD;
				}

				// ok
				return buttonType;
			}
		}
		#endregion

		/// Update
		public override void Update()
		{
			// call base
			base.Update();

			// set icons
			if (ButtonAddRemoveACDType == eButtonType.AddToACD)
			{
				buttonAddRemoveACD.ImageNormal = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDAddNormal");
				buttonAddRemoveACD.ImageDisabled = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDAddDisabled");
				buttonAddRemoveACD.ImageHot = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDAddHot");
			}
			else
			{
				// set icons
				buttonAddRemoveACD.ImageNormal = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDRemoveNormal");
				buttonAddRemoveACD.ImageDisabled = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDRemoveDisabled");
				buttonAddRemoveACD.ImageHot = EFS.Common.UI.Resources.ImageSource.Cache.GetSource("Icon_AgentACDRemoveHot");
			}

			// update skill
			EFS.RC.CC.Messages.Agents.Skills.Skill skill = AgentStatus.GetSkill(RequiredSkillId);
			if (null != skill)
			{
				controlSkilledColor.SkilledValue = skill.Value;
			}
		}

		#region Events
		/// Loaded
		private void ContactListItemNotTalking_Loaded(object sender, System.Windows.RoutedEventArgs e)
		{
			Update();
		}

		/// Add/Remove from ACD
		private void buttonAddRemoveACD_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			// call
			OnButtonClicked(e, ButtonAddRemoveACDType, Source, ACD);
		}
		#endregion
	}

}